//
//  OrderCell.swift
//  SWfanghu
//
//  Created by 赵宇桥 on 16/6/7.
//  Copyright © 2016年 ly. All rights reserved.
//

import Foundation
import UIKit
class OrderCell: UITableViewCell {
    // MARK: property
    static private let identifier = "OrderCell"
    //MARK: - 初始化子控件
    private lazy var white:UIView = {
    let white = UIView()
        white.backgroundColor = UIColor.whiteColor()
        return white
    }()
    
    private lazy var orderNum: UILabel = {
        let orderNum = UILabel()
        orderNum.font = UIFont.systemFontOfSize(15)
        orderNum.text = "订单号213123123123"
        return orderNum
    }()
    private lazy var t1: UILabel = {
        let t1 = UILabel()
        t1.font = UIFont.systemFontOfSize(14)
        t1.text = "房屋地址："
        return t1
    }()
    private lazy var adress: UILabel = {
        let adress = UILabel()
        adress.font = UIFont.systemFontOfSize(14)
        return adress
    }()
    
    private lazy var t2: UILabel = {
        let t2 = UILabel()
        t2.font = UIFont.systemFontOfSize(14)
        t2.text = "提交时间："
        return t2
    }()
    private lazy var time: UILabel = {
        let time = UILabel()
        time.font = UIFont.systemFontOfSize(14)
        return time
    }()
    
    private lazy var t3: UILabel = {
        let t3 = UILabel()
        t3.font = UIFont.systemFontOfSize(14)
        t3.text = "评估价格："
        return t3
    }()
    private lazy var price: UILabel = {
        let price = UILabel()
        price.font = UIFont.systemFontOfSize(14)
        return price
    }()
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.backgroundColor = UIColor.clearColor()
        backgroundColor = UIColor.clearColor()
        
        addSubview(white)
        white.addSubview(orderNum)
        white.addSubview(t1)
        white.addSubview(adress)
        white.addSubview(t2)
        white.addSubview(time)
        white.addSubview(t3)
        white.addSubview(price)
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    class func cellWithTableView(tableView: UITableView) -> OrderCell {
        var cell = tableView.dequeueReusableCellWithIdentifier(identifier) as? OrderCell
        if cell == nil {
            cell = OrderCell(style: .Default, reuseIdentifier: identifier)
        }
        return cell!
    }
    
    // MARK: - layout
    override func layoutSubviews() {
        super.layoutSubviews()
        
        let width: CGFloat = 640
        white.frame = CADipRectMake(0, 0, width, 88+60*3)
        
        let line = UIView(frame: CADipRectMake(0, 88, width, 2))
        line.backgroundColor = color_line
        white.addSubview(line)
        
        orderNum.frame = CADipRectMake(spaceHeight, 0, width, 88)
        
        let w = getStringWidthBy("房屋地址：", font: t1.font.pointSize)
        t1.frame = CADipRectMake(spaceHeight, 88, w, 60)
        adress.frame = CADipRectMake(spaceHeight+w, 88, width-t1.frame.maxX, 60)
        
        t2.frame = CADipRectMake(spaceHeight, 88+60, w, 60)
        time.frame = CADipRectMake(spaceHeight+w, 88+60, width-t1.frame.maxX, 60)
        
        t3.frame = CADipRectMake(spaceHeight, 88+60*2, w, 60)
        price.frame = CADipRectMake(spaceHeight+w, 88+60*2, width-t1.frame.maxX, 60)
    }
}